#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
class Solution {
public:
    string longestPalindrome(string s) {
        int len=0,begin=0;
        for(int i=0;i<s.size();i++)
        {
            //1
            int left=i,right=i;
            while(left>=0&&right<s.size()&&s[left]==s[right]) left--,right++;
            if(right - left -1 >len)
            {
                begin=left+1;
                len=right-left-1;
            }
            //2
            left=i,right=i+1;
           while(left>=0&&right<s.size()&&s[left]==s[right]) left--,right++;
             if(right - left -1 >len)
            {
                begin=left+1;
                len=right-left-1;
            }
        }
        return s.substr(begin,len);
    }
};